package dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import oracle.net.aso.r;
import pojo.User;
import util.DBUtil;
import dao.UserDao;

public class UserDaoImpl implements UserDao{

	@Override
	public User findUserByName(String name) {
		Connection con=null;
		con=DBUtil.createConnection();
		PreparedStatement ps=null;
		ResultSet rs=null;
		String sql="select * from alluser where name=?";
		User user=null;
		try {
			ps=con.prepareStatement(sql);
			ps.setString(1, name);
			rs=ps.executeQuery();
			while(rs.next())
			{
				user=new User();
				user.setId(rs.getString(1));
				user.setName(rs.getString(2));
				user.setPassword(rs.getString(3));
			}
		} catch (Exception e) {
			
		}finally
		{
			DBUtil.close(null,con,ps);
		}
		
		return user;
	}

}
